<?php 
require_once '../data/connect.class.php';
$connect = new Connect("localhost","root","","email");
$param = $_POST['param'];

if (isset($param)) {
	if ($param=='list') {
		$querySql="select * from admin_user;";
		$resultSet = $connect->execute($querySql);
		echo "<div class='page_user_row'><div class='page_user_content'><strong>用户名</strong></div><div class='page_user_content'><strong>操作</strong></div></div>";
		foreach($resultSet as $res) {
			echo "<div class='page_user_row'><div class='page_user_content'>".$res['name']."</div><div class='page_user_content' onclick='removeUser(\"".$res['id']."\")' style='cursor:pointer;'>删除</div></div>";
		}
	}elseif($param=='add') {
		echo "<label>用户名</label>"; 
		echo "<input type='text' id='add_name' value='' />"; 
		echo "<label>密码</label>"; 
	    echo "<input type='password' id='add_password' value='' />"; 
	    echo "<div onclick='addUser()' style='cursor:pointer;'>确定</div>";
	    
	}elseif($param=='privilege') {
		echo "当前用户：<div class='page_user_selected' onclick='showUsers()'>请点击选择用户</div>";
		$sql = "select * from admin_user";
		$resultSet = $connect->execute($sql);
		
		echo "<div class='page_user_list'>";
	    foreach($resultSet as $res) {
        	echo "<div class='page_user_list_item' onclick='selectUser(this,\"".$res['id']."\")'>";
        	echo $res['name'];
        	echo "</div>";
        }
		echo "</div>";
		
		$sql = "select * from admin_page";
        $resultSet = $connect->execute($sql);
        
        echo "<input type='checkbox' id='allSelector' onclick='selectAll()'>全选<br/>";
        foreach($resultSet as $res) {
        	echo "<input type='checkbox' name='checkbox' value='".$res['id']."'>";
        	echo $res['name']."<br/>";
        }
        
        echo "<div style='cursor:pointer;' onclick='submitPrivilege()'>提交</div>";
	}
}

?>